<template>
  <div>
    <!-- 搜索条件 -->
    <el-form :inline="true" class="demo-form-inline" style="margin:10px 0px 0px 10px">

      <el-form-item label="角色名称">
        <el-input v-model="gameRoleVo.gameName" clearable placeholder="角色名称" />
      </el-form-item>

      <el-form-item label="房间号">
        <el-input v-model="gameRoleVo.roomId" clearable placeholder="房间号" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="tableData.current=1,getList()">查询</el-button>
        <el-button type="primary" @click="resetData()">清空</el-button>
      </el-form-item>

      <el-form-item float:right>
        <a
          href="https://www.fengshu.press/serviceucenter/gamerole/getGameRoleInfoAddExcel"
          target="_blank"
        ><el-button type="primary">excel</el-button></a>
      </el-form-item>
    </el-form>

    <!-- 列表数据 -->
    <el-table
      :data="tableData.list"
      border
      style="width: 100%"
    >

      <el-table-column align="center" label="序号">
        <template slot-scope="scope">
          {{ scope.$index +1 }}
        </template>
      </el-table-column>

      <el-table-column
        prop="roomId"
        label="房间号"
        width="320px"
      />

      <el-table-column
        prop="gameName"
        label="角色名称"
        width="320px"
      />

      <el-table-column
        prop="gameQixue"
        label="气血"
        width="320px"
      />

      <el-table-column
        prop="gameArmor"
        label="速度"
        width="320px"
      />
      <!--
      <el-table-column
        label="操作"
        width="320px">
        <template slot-scope="scope" >
            <a :href="'#/hecheng/addOrUpdateHeCheng?id='+scope.row.id">
              <el-button type="primary" icon="el-icon-edit" circle></el-button>
            </a>
            <el-button type="danger"  @click="deleteHeChengProps(scope.row.id)" icon="el-icon-delete" circle style="margin-left:10px"></el-button>
        </template>
      </el-table-column>     -->
    </el-table>

    <el-pagination
      background
      layout="prev, pager, next"
      :total="tableData.total"
      :page-size="tableData.limit"
      :current-page="tableData.current"
      @current-change="tableData.current=$event,getList()"
    />

  </div>
</template>

<script>
import gameroleinfo from '@/api/gameroleinfo'

export default {
  data() { // 定义变量和初始值
    return {
      tableData: {
        total: 1000,
        current: 1,
        limit: 10,
        list: []
      },
      gameRoleVo: {},
      gameRoleVo1: {}
    }
  },
  created() { // 页面渲染之前执行，一般调用methods定义的方法
    // 获取所有角色列表
    // this.getAllRoleList()
    // 合成道具列表
    this.getList()
  },
  methods: { // 创建具体的方法，调用.js定义的方法
    // 获取合成道具列表
    getList() {
      this.$loading = true
      gameroleinfo.getAllGameRole(this.tableData.current, this.tableData.limit, this.gameRoleVo).then(res => {
        console.log(res.data.rows)
        // 数据赋值
        this.tableData.list = res.data.rows
        this.tableData.total = res.data.total
      }).then(error => {
        this.$loading = false
      })
    },
    // 清空数据
    resetData() {
      // 查询表单清空
      this.gameRoleVo = {},
      // 查询所有讲师数据
      this.getList()
    },
    getGameRoleInfoAddExcel() {
      gameroleinfo.getGameRoleInfoAddExcel()
        .then(() => {
          this.$message({
            type: 'info',
            message: '成功'
          })
        })
    }
    // 删除道具
    // deleteHeChengProps(id){
    //     //提示框
    //     this.$confirm('是否删除该合成道具', '提示', {
    //       confirmButtonText: '确定',
    //       cancelButtonText: '取消',
    //       type: 'warning'
    //     }).then(() => {
    //       //执行删除
    //       HCApi.deleteHeChengProps(id).then(res => {
    //         //执行后提示
    //         this.$message({
    //           message: '删除成功',
    //           type: 'success'
    //         });
    //         this.getHCList()
    //     })
    //   }).catch(() => {
    //     //捕捉异常
    //     this.$message({
    //       type: 'info',
    //       message: '已取消'
    //     });
    //   });
    // }
  }
}
</script>
